@import 'mediawiki.mixins.less';
@import 'mediawiki.ui/mixins.buttons.less';
@import 'mediawiki.ui/variables.less';

/* stylelint-disable selector-class-pattern */

// All buttons start with `.mw-ui-button` class, modified by other classes.
// It can be any element.  Due to a lack of a CSS reset, the exact styling of
// the button depends on what type of element is used.
// There are two kinds of buttons, the default is a "Call to Action" with an obvious border
// and there is a quiet kind without a border.

// Neutral button styling
//
// These are the main actions on the page/workflow. The page should have only one of progressive and destructive buttons, the rest being quiet.
//
// Markup:
// <div>
//   <button class="mw-ui-button">.mw-ui-button</button>
// </div>
// <div>
//   <button class="mw-ui-button" disabled>.mw-ui-button</button>
// </div>
.mw-ui-button {
	background-color: @colorGray15;
	color: @colorButtonText;
	.mw-ui-button();
	.mw-ui-button-states();

	// Styling for specific button types
	// -----------------------------------------

	// Quiet buttons
	//
	// Use quiet buttons when they are less important and alongside other progressive or destructive buttons. It should be used for an action that exits the user from the current view/workflow.
	// Its use is  not recommended on mobile/tablet due to lack of hover state.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-quiet">.mw-ui-button</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-quiet">.mw-ui-destructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-quiet" disabled>.mw-ui-destructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-quiet">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-quiet" disabled>.mw-ui-progressive</button>
	// </div>
	&.mw-ui-quiet,
	&.mw-ui-quiet.mw-ui-progressive,
	&.mw-ui-quiet.mw-ui-destructive {
		background-color: transparent;
		// Quiet buttons all start gray, and reveal
		// progressive/destructive color on hover and active.
		color: @colorButtonText;
		border-color: transparent;

		&:hover {
			background-color: transparent;
			color: @colorButtonTextHighlight;
			border-color: transparent;
			box-shadow: none;
		}

		&:active {
			background-color: transparent;
			color: @colorButtonTextActive;
			border-color: transparent;
		}

		&:focus {
			background-color: transparent;
			color: @colorButtonText;
			border-color: transparent;
			box-shadow: none;
		}

		&:disabled,
		&:disabled:hover,
		&:disabled:active {
			background-color: transparent;
			color: @colorDisabledText;
			border-color: transparent;
		}
	}

	// Progressive buttons
	//
	// Use progressive buttons for actions which lead to a next step in the process.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive" disabled>.mw-ui-progressive</button>
	// </div>
	&.mw-ui-progressive {
		.mw-ui-button-colors-primary( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );

		&.mw-ui-quiet {
			color: @colorProgressive;

			&:hover {
				background-color: transparent;
				color: @colorProgressiveHighlight;
			}

			&:active {
				color: @colorProgressiveActive;
			}

			&:focus {
				background-color: transparent;
				color: @colorProgressive;
			}
		}
	}

	// Destructive buttons
	//
	// Use destructive buttons for actions that remove or limit, such as deleting a page or blocking a user.
	// This should not be used for cancel buttons.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive">.mw-ui-destructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive" disabled>.mw-ui-destructive</button>
	// </div>
	&.mw-ui-destructive {
		.mw-ui-button-colors-primary( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );

		&.mw-ui-quiet {
			color: @colorDestructive;

			&:hover {
				background-color: transparent;
				color: @colorDestructiveHighlight;
			}

			&:active {
				color: @colorDestructiveActive;
			}

			&:focus {
				background-color: transparent;
				color: @colorDestructive;
			}
		}
	}

	// Big buttons
	//
	// Not all buttons are equal. You can emphasise certain actions over others
	// using the mw-ui-big class.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-big">.mw-ui-button</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-big">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-big">.mw-ui-destructive</button>
	// </div>
	&.mw-ui-big {
		font-size: 1.3em;
	}

	// Block buttons
	//
	// Some buttons might need to be stacked.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-block">.mw-ui-button</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-block">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-block">.mw-ui-destructive</button>
	// </div>
	&.mw-ui-block {
		display: block;
		width: 100%;
		margin-left: auto;
		margin-right: auto;
	}
}

input.mw-ui-button,
button.mw-ui-button {
	// Buttons in Firefox have extra height
	&::-moz-focus-inner {
		margin-top: -1px;
		margin-bottom: -1px;
	}
}

a.mw-ui-button {
	text-decoration: none;

	// This overrides an underline declaration on a:hover and a:focus in
	// commonElements.css, which the class alone isn't specific enough to do.
	&:hover,
	&:focus {
		text-decoration: none;
	}
}

// Button groups
//
// Group of buttons. Make sure you clear the floating after using a mw-ui-button-group.
//
// Markup:
// <div class="mw-ui-button-group">
//   <div class="mw-ui-button is-on">A</div>
//   <div class="mw-ui-button">B</div>
//   <div class="mw-ui-button">C</div>
//   <div class="mw-ui-button">D</div>
// </div><div style="clear:both"></div>
.mw-ui-button-group {
	& > * {
		min-width: 48px;
		border-radius: 0;
		float: left;

		&:first-child {
			border-top-left-radius: @border-radius-base;
			border-bottom-left-radius: @border-radius-base;
		}

		&:not( :first-child ) {
			border-left: 0;
		}

		&:last-child {
			border-top-right-radius: @border-radius-base;
			border-bottom-right-radius: @border-radius-base;
		}
	}

	& .is-on .button {
		cursor: default;
	}
}
